home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 32
/
Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso
/
Aminet
/
biz
/
dopus
/
dopus_undms.lha
/
undms.dopus5
< prev
Wrap
Text File
|
1999-05-13
|
4KB
|
155 lines
/*
* $VER: undms.dopus5 2.21 (13.05.99)
*
* ARexx script for DOpus 5.8+
* Enhanced for DOpus5.8+ by A Niven-Jenkins © 1999 Cremlin Software
* Original script by Edmund Vermeulen
*
* Unpacks a DMS file to disk with progress indication
*
* ARexx: <path>undms.dopus5 {Qp} {f}
* Flags: Run asynchronously
*
*/
PARSE ARG dopusport filepath .
OPTIONS RESULTS
SIGNAL ON ioerr
/* initial variable values */
filepath=STRIP(filepath, 'B', '"')
devices='_DF0 D_F1'
automount='FF_0 FF_1'
lf='0a'x
buttons=''
num=0
break=0
errorreport=''
buffer=''
ADDRESS VALUE dopusport
/* get filename from complete path */
charpos=LASTPOS('/', filepath)
IF charpos=0 THEN charpos=POS(':', filepath)
filename=SUBSTR(filepath, charpos+1)
/* only show devices which are actually available */
DO WHILE devices~=''
PARSE VAR devices devbutton devices
dest=COMPRESS(devbutton, '_')
IF SHOWLIST('H', dest) THEN DO
num=num+1
dest.num=dest || ':'
buttons=buttons || devbutton || ' |'
END
END
/* add automount devices */
DO WHILE automount~=''
num=num+1
PARSE VAR automount devbutton automount
dest.num=COMPRESS(devbutton, '_') || ':'
buttons=buttons || devbutton || ' |'
END
DOPUS REQUEST '"Please select destination for ' || filename || '" ' || buttons || ' _Cancel'
/* if cancel wasn't clicked carry on */
IF RC>0 THEN DO
/* get device from button cicked */
devname=dest.RC
/* if device is an automount, mount it */
IF ~SHOWLIST('H', devname) THEN ADDRESS COMMAND 'Mount' devname
/* setup progress bar */
DOPUS PROGRESS INFO BAR ABORT
handle=RESULT
DOPUS PROGRESS handle title 'Unpacking ' || filename || '...'
/* start running DMS via PIPE: */
ADDRESS COMMAND 'Run >T:UnDMS.' || handle || ' <NIL: DMS <NIL: >PIPE:dmsout.' || handle || ' WRITE "' || filepath || '" TO ' || devname || ' NOTEXT'
/* get CLI process number */
OPEN('tempfile', 'T:UnDMS.' || handle, 'R')
PROCESS=READLN('tempfile')
PARSE VAR PROCESS '[CLI ' process ']'
CLOSE('tempfile')
DELETE('T:UnDMS.' || handle)
/* read in PIPE: information so that the progress bar can be updated */
OPEN('dmsout', 'PIPE:dmsout.' || handle, 'R')
DO UNTIL EOF('dmsout')
/* read in 25 characters at a time */
buffer=buffer || READCH('dmsout', 25)
/* check for a new line */
newline=VERIFY(buffer, '0a0d'x, 'M')
/* if we are on a newline */
IF newline>0 THEN DO
/* one whole line */
line=LEFT(buffer, newline-1)
/* was abort clicked */
DOPUS PROGRESS handle ABORT
/* if it wasn't carry on */
IF RESULT=0 THEN DO
/* no disk in drive */
IF LEFT(UPPER(line), 7)='NO DISK' THEN DOPUS PROGRESS handle INFO 'Please insert disk in ' || devname
/* inserted disk is write protected */
IF POS('WRITE-PROTECTED', UPPER(line))>0 THEN DOPUS PROGRESS handle INFO 'Disk in ' || devname || ' is write protected.'
/* get rid of some ugly stuff */
PARSE VAR line ' ' line
buffer=SUBSTR(buffer, newline+1)
/* remember every line with the word 'error' in it */
IF POS('ERROR', UPPER(line))>0 THEN DO
errorreport=errorreport || lf || line
COMMAND FLASH
END
/* update progress bar */
IF POS('UNPACKING', UPPER(line))>0 THEN DO
track=RIGHT(line, 2)
DOPUS PROGRESS handle INFO 'Track ' || track
DOPUS PROGRESS handle BAR 80 track+1
END
END
ELSE DO
break=1
CALL endpart
END
END
END
/* display error report */
IF errorreport~=='' THEN DOPUS REQUEST '"DMS error report for ' || dmsname || lf || errorreport || '" _OK'
/* on error */
ioerr:;endpart:
/* shut down DMS */
IF break=1 THEN DO
ADDRESS COMMAND 'Break ' || process || ' C'
CLOSE('dmsout')
END
/* clean up */
DOPUS PROGRESS handle OFF
END
/* end gracefully */
EXIT 0